﻿using NewsSystem.Data.Migrations;
using NewsSystem.Models;
using System.Data.Entity;

namespace NewsSystem.Data
{
    public class NewsContext : DbContext
    {
        static NewsContext()
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<NewsContext, Configuration>());
        }

        public NewsContext() : base("NewsDb")
        {
        }

        public DbSet<Article> Articles { get; set; }

        public DbSet<User> Users { get; set; }

        public DbSet<Image> Images { get; set; }

        public DbSet<Comment> Comments { get; set; }

        public DbSet<Vote> Votes { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //// modelBuilder.Entity<Tag>().Property(x => x.Text).IsFixedLength();
            //// modelBuilder.Configurations.Add(new TagMappings());
            base.OnModelCreating(modelBuilder);
        }
    }
}